this.BX=this.BX||{};(function(e,t){"use strict";var f=function(e){babelHelpers.inherits(f,e);function f(e,t,i){var a;babelHelpers.classCallCheck(this,f);a=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(f).call(this));a.setEventNamespace("BX.Landing.ColorPickerTheme");a.element=e;a.input=a.element.firstElementChild;a.allColors=t;a.currentColor=i;a.init();return a}babelHelpers.createClass(f,[{key:"init",value:function e(){this.setMetric();var t=this.initPreviewColor();var f=this.isActive();this.element.style.backgroundColor=t;this.element.dataset.value=t;this.element.classList.add("landing-colorpicker-theme");if(f){this.input.setAttribute("value",t);this.element.classList.add("active")}this.colorPicker=new BX.ColorPicker({bindElement:this.element,popupOptions:{angle:false,offsetTop:5},onColorSelected:this.onColorSelected.bind(this),colors:this.getGridColors(),selectedColor:this.getSelectedColor()});BX.bind(this.element,"click",this.open.bind(this))}},{key:"setMetric",value:function e(){this.metrika=null;if(typeof BX.Landing.Metrika!=="undefined"){this.metrika=new BX.Landing.Metrika}}},{key:"initPreviewColor",value:function e(){var t;if(this.currentColor){if(this.isHex(this.currentColor)){t=this.isBaseColor()?f.DEFAULT_COLOR_PICKER_COLOR:this.currentColor}else{t=f.DEFAULT_COLOR_PICKER_COLOR}}else{t=f.DEFAULT_COLOR_PICKER_COLOR}return t}},{key:"isActive",value:function e(){if(!this.isHex(this.currentColor)){return false}return!this.isBaseColor()}},{key:"isBaseColor",value:function e(){return this.allColors.includes(this.currentColor)}},{key:"getSelectedColor",value:function e(){var t;if(this.element.dataset.value){t=this.element.dataset.value}t=this.prepareColor(t);if(!this.isHex(t)){t=""}return t}},{key:"onColorSelected",value:function e(f){this.element.classList.add("ui-colorpicker-selected");this.element.dataset.value=f.substr(1);this.element.style.backgroundColor=f;var i=new t.BaseEvent({data:{color:f,node:this.element}});this.emit("onSelectColor",i);this.emit("onSelectCustomColor",i);this.input.setAttribute("value",f);this.sendMetric(f)}},{key:"sendMetric",value:function e(t){if(this.metrika){this.metrika.sendLabel(null,"Color::CustomSet",t.substr(1))}}},{key:"open",value:function e(){this.colorPicker.open()}},{key:"getGridColors",value:function e(){return[["#f4f5fb","#d2d6ef","#b0b8e3","#8f99d6","#6d7bca","#4b5cbe","#3e4fac"],["#eaecfb","#d5daf6","#c0c7f2","#abb5ed","#96a2e9","#8190e4","#7888e2"],["#e8f4fc","#d1e9fa","#badef7","#a3d3f5","#8cc8f2","#75bdf0","#6cb8ef"],["#ebfaf8","#caf1ed","#aeeae3","#9ae5dc","#85e0d5","#71dace","#5dd5c7"],["#eafbf9","#c8f4f0","#aaeee8","#90e9e2","#5ddfd4","#2ad5c7","#26c0b3"],["#ebfaf0","#d6f5e2","#c2f0d3","#adebc5","#99e6b6","#85e0a8","#70db99"],["#f6f9eb","#e8efcc","#dbe7b1","#d1e09a","#c4d77e","#b8cf63","#a9c544"],["#fafee6","#f3febe","#edfd9b","#e8fc82","#d0e859","#b5d31d","#a7c804"],["#fefee6","#fdfcce","#fcfbb6","#fbf993","#f9f771","#f7f445","#f6f223"],["#fef8e6","#fdf1ce","#fdeab5","#fce092","#fbd570","#f9c943","#f8bc16"],["#fde9e8","#fbd3d0","#f9bdb9","#f7a7a1","#f5918a","#f27269","#ee463a"],["#f9ebeb","#f4d7d7","#eec4c4","#e8b0b0","#e29c9c","#d77575","#ca4949"],["#fceae8","#f9d6d2","#f7c1bb","#f4aca4","#f1978e","#ee8377","#e75140"],["#ffe6e6","#ffd1d2","#ffc2c3","#ffa9aa","#fe9496","#fe8082","#fe6769"],["#fee8e7","#fdd2ce","#fcbbb6","#fba59d","#fa8e85","#f9786c","#f75445"],["#ffe5e5","#fcc","#ffb3b3","#f99","#ff8080","#f66","#ff0a0a"],["#fee7ea","#fdced6","#fcb6c1","#fb9dad","#fa8598","#f96c84","#f73b5a"],["#fde7ef","#fbd0df","#f9b8cf","#f7a1bf","#f580a9","#f25a8f","#ec135f"],["#faeaef","#f5d6de","#f0c1ce","#ebadbd","#e698ad","#e1849d","#d75b7c"],["#f2f2f2","#dedede","#ccc","#b3b3b3","#999","#666","#404040"]].map((function(e,t,f){return f.map((function(e){return e[t]}))}))}},{key:"prepareColor",value:function e(t){if(t[0]!=="#"){t="#"+t}return t}},{key:"isHex",value:function e(t){var i=false;if(t.length===4||t.length===7){if(t.match(f.MATCH_HEX)){i=true}}return i}}]);return f}(t.EventEmitter);babelHelpers.defineProperty(f,"DEFAULT_COLOR_PICKER_COLOR","#f25a8f");babelHelpers.defineProperty(f,"MATCH_HEX",/#?([0-9A-F]{3}){1,2}$/i);e.ColorPickerTheme=f})(this.BX.Landing=this.BX.Landing||{},BX.Event);
//# sourceMappingURL=colorpickertheme.bundle.map.js